// 定时任务
var intervalTask=null;
function globalTask(){
	//当处于电子巡更状态的时候，不执行
	if (elePatrolObj.operationName!='none'){
      return;		
	}
	
	//TODO ,必须清除掉已经不在告警清单中的颜色	
	if (publicAlarmObj.isLock){
		return;
	}
	
	publicAlarmObj.isWorking=true;
	//////////////////////////////////////////////////////////////////////////
	//建筑和多层模型闪烁
    if (map.isGlobalScene) {
		modelMap.globalBuildingTagIdList.forEach(function (item) {
			let isWarnning=(publicAlarmObj.alarmGlobalBuildingTagList.indexOf(item)!=-1);
			let buildNode=g3d.dm().getDataByTag(item);
			if (buildNode!=undefined){
				let buildName=modelMap.globalBuildingNameList[item];
				if (!isWarnning){
					buildNode.setStyle('body.color', '#fff');				
				}
				else{
					buildNode.getStyle('body.color') === buildcolor?buildNode.setStyle('body.color', '#fff'):buildNode.setStyle('body.color', buildcolor);
                    //重新设定告警名称
                    buildName=buildName+" | "+publicAlarmObj.alarmBuildingSummary.get(item);				
				}
				let billChild=buildNode.getAttaches().get(0);
				if (billChild.a('msg')!=buildName){
				   billChild.a('msg',buildName);
				}
				//刷新缓存
		        //g3d.invalidateShape3dCachedImage(billChild);
				//publicAlarmObj.refreshBuildingBillBoard(item,buildName);
			}
			
		});
	} else {
		for (x in modelConfig.floorNoList){
			let floorModelId=modelMap.curModelIdPrefix+"_"+modelConfig.floorNoList[x];			
            let isWarnning=(publicAlarmObj.alarmModelIdList.indexOf(floorModelId)!=-1);
			let floorNode=g3d.dm().getDataByTag(floorModelId);
			if (floorNode!=undefined){
				let isMultiFloor=modelMap.isMultiFloor(floorModelId);
				if (isWarnning){
					if (isMultiFloor){						
						floorNode.s('shape3d.color') === buildFloorColor ? floorNode.s('shape3d.color', 'rgba(0,0,0, 0)') : floorNode.s('shape3d.color', buildFloorColor);
					}
					else if (floorNode.s('all.color')){
						floorNode.s('all.color') === buildFloorColor ? floorNode.s('all.color', 'rgba(0,0,0, 0)') : floorNode.s('all.color', buildFloorColor);
					}
				}
				else{
					if (isMultiFloor){
						if (modelMap.curShowingFloorName!= floorNode._displayName){
							floorNode.s('shape3d.color', 'rgba(0,0,0,0)');
						}
						else if (modelMap.curShowingFloorName== floorNode._displayName){
							floorNode.s('shape3d.color', 'rgba(0,0,0,0.4)');
						}
					}
					else{
						if (modelMap.curShowingFloorName!= floorNode._displayName){ //不在鼠标移动范围内
							floorNode.s('all.color', 'rgba(0,0,0,0)');
						}
						else if (modelMap.curShowingFloorName== floorNode._displayName){
							floorNode.s('all.color', 'rgba(0,0,0,0.4)');
						}
					}
				}
			}
		}
	}
	////////////////////////////////////////////////////////////////////////
	//刷先告警设备标记
	//添加不在old中的设备
	publicAlarmObj.alarmDeviceIdList.forEach(function(deviceId){
		let newNode=g3d.dm().getDataByTag(deviceId);
		if  (newNode!=undefined){
			publicAlarmObj.createFlag(newNode.getPosition3d(), newNode,true,null,null);
		}	
	});
	
	//清除不在其中的设备信息
	publicAlarmObj.oldAlarmDeviceIdList.forEach(function(deviceId){
		if (publicAlarmObj.alarmDeviceIdList.indexOf(deviceId)==-1){
			let oldNode=g3d.dm().getDataByTag(deviceId);			
			if  (oldNode!=undefined){
				//清除设备颜色
				oldNode.setStyle('body.color',undefined);
				let child=oldNode.getAttaches();
				if (child!=undefined ){
					let childCount=child.length;
					let childIdArr=new Array();
					for(i=0;i<childCount;i++){
						childIdArr.push(child.get(i).getId());
					}
			        
					for(i=0;i<childCount;i++){
						g3d.dm().removeDataById(childIdArr[i]);
					}
					
					child.clear();
					
				}
			}
		}
	});
	
	publicAlarmObj.isWorking=false;
};